package com.example.photography.adapter.focus;

import android.content.Context;
import android.net.Uri;
import android.view.View;
import android.widget.TextView;

import com.example.photography.R;
import com.example.photography.adapter.MyBaseAdapter;
import com.example.photography.bean.FocusBean;
import com.facebook.drawee.view.SimpleDraweeView;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public abstract class FansAdapter extends MyBaseAdapter {
    public FansAdapter(List list, Context context) {
        super(list, context);
    }

    @Override
    public View myGetView(int position, View convertView) {
        ViewHolder holder = null;
        if (convertView == null) {
            convertView = View.inflate(mContext, R.layout.item_user, null);
            holder = new ViewHolder(convertView);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        //装载数据
        FocusBean.DataBean.FanssBean fanssBean = (FocusBean.DataBean.FanssBean) list.get(position);
        holder.svImage.setImageURI(Uri.parse(fanssBean.getImage()));
        holder.tvName.setText(fanssBean.getName());
        holder.tvIdentify.setText(fanssBean.getIdentity());
        if (!fanssBean.isIsfocus()){
            holder.tvFocus.setVisibility(View.VISIBLE);
        }

        holder.tvFocus.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                focus();
            }
        });
        return convertView;
    }

    static
    class ViewHolder {
        @BindView(R.id.sv_image)
        SimpleDraweeView svImage;
        @BindView(R.id.tv_name)
        TextView tvName;
        @BindView(R.id.tv_identify)
        TextView tvIdentify;
        @BindView(R.id.tv_focus)
        TextView tvFocus;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
    public abstract void focus();
}
